//
//  HomeJXCell.m
//  ai2ban
//
//  Created by Luolc on 2018/1/9.
//  Copyright © 2018年 mac book pro. All rights reserved.
//

#import "HomeJXCell.h"
#import "HomeGoodView.h"

@implementation HomeJXCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self initTheUI];
        
        
    }
    
    return self;
}

- (void)initTheUI {
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor whiteColor];
    
    UILabel *label = [[UILabel alloc] init];
    label.frame = CGRectMake(17, 9.6, kScreen_Width, 24);
    label.text = @"天上馅饼 惊喜通兑";
    label.font = [UIFont fontWithName:@"HYk2gj" size:13.4];
    label.textColor = [UIColor colorWithRed:255/255.0 green:104/255.0 blue:26/255.0 alpha:1];
    [self.contentView addSubview:label];
    
    
    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.frame = CGRectMake(0, label.bottom+9.5, kScreen_Width, HomeGoodViewHeight);
    [self.contentView addSubview:scrollView];
    
    NSArray *titles = @[@"苏泊尔supor无油烟炒锅",@"苏泊尔supor无油烟炒锅",@"苏泊尔supor无油烟炒锅",@"苏泊尔supor无油烟炒锅",@"苏泊尔supor无油烟炒锅"];
    
    CGFloat letfmarin = 27;
    CGFloat itemMarign = 18;
    [titles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        CGFloat x = letfmarin +idx*(itemMarign+HomeGoodViewWith);
        
        CGRect frame = CGRectMake(x, 0, HomeGoodViewWith, HomeGoodViewHeight);
        
        HomeGoodView *good = [[HomeGoodView alloc] initWithFrame:frame andIcon:@"" andTitle:titles[idx] andPrice:@"9999积分"];
        [scrollView addSubview:good];
        
        
    }];
    
    [scrollView setContentSize:CGSizeMake(scrollView.subviews.lastObject.right+letfmarin, 0)];
    
    
}
@end
